import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import {
  AntDesignVueResolver,
} from 'unplugin-vue-components/resolvers';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { createStyleImportPlugin, AndDesignVueResolve } from 'vite-plugin-style-import';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
// @ts-ignore
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/icons')],
      symbolId: 'icon-[name]',
    }),
    createStyleImportPlugin({
      resolves: [AndDesignVueResolve()],
    }),
    Components({
      dts: true,
      resolvers: [
        AntDesignVueResolver(),
      ],
    })],
  resolve: {
    alias: [
      { find: '@', replacement: path.resolve(process.cwd(), './src') },
      {
        find: '@c',
        replacement: path.resolve(process.cwd(), './src/components'),
      },
      {
        find: '@img',
        replacement: path.resolve(process.cwd(), './src/assets/image'),
      },
    ],
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
});
